//
//  HuangwwGestureVerifyViewController.m
//  Huangww
//
//  Created by huangwenwu on 2020/1/15.
//  Copyright © 2019 HuangwwFaceAndGesture. All rights reserved.
//

#import "HuangwwGestureVerifyViewController.h"
#import "HuangwwPCCircleView.h"
#import "HuangwwPCCircleViewConst.h"
#import "HuangwwPCLockLabel.h"
#import "HuangwwPCCircleInfoView.h"
#import "HuangwwPCCircle.h"
#import "HuangwwDrawGestureViewController.h"
@interface HuangwwGestureVerifyViewController ()<CircleViewDelegate>

@property (nonatomic, strong) HuangwwPCLockLabel *msgLabel;

@end

@implementation HuangwwGestureVerifyViewController



- (void)viewDidLoad {
    self.viewModel = [[FULIBaseRefreshViewModel alloc] init];
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.touchEndEditing = NO;
    self.realNavigationBarItem.title = @"验证手势解锁";
    [self.view setBackgroundColor:CircleViewBackgroundColor];
    HuangwwPCCircleView *lockView = [[HuangwwPCCircleView alloc] init];
    lockView.delegate = self;
    [lockView setType:CircleViewTypeVerify];
    [self.view addSubview:lockView];
    
    HuangwwPCLockLabel *msgLabel = [[HuangwwPCLockLabel alloc] init];
    msgLabel.frame = CGRectMake(0, 0, kScreenW, 14);
    msgLabel.center = CGPointMake(kScreenW/2, CGRectGetMinY(lockView.frame) - 30);
    [msgLabel showNormalMsg:gestureTextOldGesture];
    self.msgLabel = msgLabel;
    [self.view addSubview:msgLabel];
}

#pragma mark - login or verify gesture
- (void)circleView:(HuangwwPCCircleView *)view type:(CircleViewType)type didCompleteLoginGesture:(NSString *)gesture result:(BOOL)equal
{
    if (type == CircleViewTypeVerify) {
        
        if (equal) {
            NSLog(@"验证成功");
            
            if (self.isToSetNewGesture) {
                HuangwwDrawGestureViewController *gestureVc = [[HuangwwDrawGestureViewController alloc] init];
                [gestureVc setType:GestureViewControllerTypeSetting];
                UINavigationController *nav = self.navigationController;
                if (nav) {
                    
                    [self.navigationController pushViewController:gestureVc animated:YES];
                }else
                {
                    [self presentViewController:gestureVc animated:YES completion:nil];
                }
            } else {
                UINavigationController *nav = self.navigationController;
                if (nav) {
                    [self.navigationController popToRootViewControllerAnimated:YES];
                }else
                {
                    [self dismissViewControllerAnimated:YES completion:nil];
                }
            }
            
        } else {
            NSLog(@"密码错误！");
            [self.msgLabel showWarnMsgAndShake:gestureTextGestureVerifyError];
        }
    }
}

- (void)circleView:(HuangwwPCCircleView *)view type:(CircleViewType)type connectCirclesLessThanNeedWithGesture:(NSString *)gesture {
    self.msgLabel.text = @"连接少于最少4个";
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
